<?php

$token = JRequest::getString('t', '');

$app = PFactory::getApplication();
$searchtokens = $app->getUserState('searchtokens', null);

if(!empty($searchtokens[$token]) && $searchtokens[$token]['count'] <= 0) {
   unset($searchtokens[$token]);
   $app->setUserState('searchtokens', $searchtokens);
}

OCP\JSON::success();